<?php

namespace app\api\controller\club;

use app\common\controller\ClubApi;

/**
 * 俱乐部小程序接口
 */
class Order extends ClubApi
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * @api {get, post} /api/club/order/place 下单接口
     * @apiGroup 订单
     * 
     * @apiParam {String} course_id 课程ID
     */
    public function place($course_id='')
    {
        try{
            if(!$course_id){
                throw new \Exception('课程ID不能为空');
            }
            $data  = [];
            $uid = $this->getService()->getLoginUid();
            $data['detail'] = $this->getService()->placeOrder($uid, $course_id); 
            return $this->success('成功', $data);
        } catch (\think\exception\HttpResponseException $e){
            throw $e;
        } catch (\Exception $e) {
            return $this->error($e->getMessage());
        }
    }
    
}
